
import utils from "../../utils/util"
Page({
  data: {
  navState: 0,//导航状态
  shuju:null,
  zuixin:null,
  rege:null,
  times: 0 as any,
  sousuo:null as any,
  },
  //监听滑块
  bindchange(e:any) {
  // console.log(e.detail.current)
  let index = e.detail.current;
  this.setData({
  navState:index
  })
  },
  //点击导航
  navSwitch: function(e:any) {
  // console.log(e.currentTarget.dataset.index)
  let index = e.currentTarget.dataset.index;
  this.setData({
  navState:index
  })

  
  },
 
  /**
  * 生命周期函数--监听页面加载
  */
  onLoad: function() {
 this.huoqu()
 this.setData({
times :utils.time(new Date()) 
 })
  },
  //获取数据测试
  huoqu(){
//编辑音乐
    wx.request({
      url: 'http://localhost:3000/top/playlist/highquality?limit=6',
      method: "GET",
      success: (result :any) => {
          // console.log(result.data.playlists)
          this.setData({
           shuju:result.data.playlists
           
          })
      },
    }),
    //最新音乐
    wx.request({
      url: 'http://localhost:3000/personalized/newsong',
      method: "GET",
      success: (result :any) => {
          // console.log(result.data.result)
          this.setData({
            zuixin:result.data.result
           
          })
      },
    })
    //热歌
    wx.request({
      url:'http://localhost:3000/playlist/detail?id=3778678',
      method:'GET',
      success:(res :any)=>{
  // console.log(res.data.playlist.tracks);
  this.setData({
    rege:res.data.playlist.tracks.slice(0,20)
  })
      }
    })
    //热门搜索
    wx.request({
      url:'http://localhost:3000/search/hot',
      method:'GET',
      success:(res :any)=>{
  // console.log(res.data.result.hots);
  this.setData({
    sousuo:res.data.result.hots
  })
      }
    })

  }
 })